package com.example.baselib.base

import android.os.Bundle
import androidx.appcompat.app.AppCompatActivity

/**
 * @auther XuDan on 2020/8/17.
 */
abstract class BaseActivity : AppCompatActivity() {
    override fun onRestoreInstanceState(savedInstanceState: Bundle) {
        super.onRestoreInstanceState(savedInstanceState)
        restoreInstanceState(savedInstanceState)
    }

    fun restoreInstanceState(savedInstanceState: Bundle) {}

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        val bundle = intent.extras
        intetData(bundle)
        setContentView(getLauoutId())
        initViews()
        initData()

    }

    abstract fun intetData(bundle: Bundle?)
    abstract fun getLauoutId(): Int
    abstract fun initViews()
    abstract fun initData()


    override fun onStart() {
        super.onStart()
    }

    override fun onPause() {
        super.onPause()
    }

    override fun onResume() {
        super.onResume()
    }

    override fun onStop() {
        super.onStop()
    }

    override fun onSaveInstanceState(outState: Bundle) {
        super.onSaveInstanceState(outState)
        saveInstanceState(outState)
    }

    fun saveInstanceState(outState: Bundle) {}

    override fun onDestroy() {
        super.onDestroy()
    }
}